from django.db import models


# Create your models here.
# 一对多关系的处理
#  一
class Publisher(models.Model):
    name = models.CharField(max_length=100)
    address = models.CharField(max_length=100)

    class Meta:
        db_table = 'publisher'


# 多
class Book(models.Model):
    title = models.CharField(max_length=100)
    price = models.IntegerField()
    # 外键  publisher_id
    publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)

    class Meta:
        db_table = 'book'


